<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <title>Hiring-求职者后台</title>
        <%@ include file="/WEB-INF/view/common/import.jsp"%>
	    <style>
	    	.resume {
	    		font-weight: bolder;
	    		font-size: 20px;
	    		margin-right: 10px;
	    	}
	    </style>
    </head>
    <body>
    	<div class="container">
    		<strong class="welcome-title">欢迎您，${talent.name }</strong>
    		<button type="button" class="btn btn-warning pull-right" onclick="location='<%=request.getContextPath()%>/TalentServlet?command=logout'">注　　销</button>
    		<span class="pull-right">&nbsp;</span>
    		<button type="button" class="btn btn-warning pull-right">修改密码</button>
    		<span class="pull-right">&nbsp;</span>
    		<button type="button" class="btn btn-warning pull-right">基本信息</button>
	    	<hr/>
	    	
	    	<span class="resume">简历管理</span>
	    	<a href="<%=request.getContextPath()%>/ResumeServlet?command=toResumeAddUI">添加简历</a>
	    	<table class="table">
		      <thead>
		        <tr>
		          <th>序号</th>
		          <th>求职意向</th>
		          <th>工作经历</th>
		          <th>项目经验</th>
		          <th>操作</th>
		        </tr>
		      </thead>
		      <tbody>
		      	<c:if test="${empty resumeList}">
		      		<tr><td colspan="5" align="center">没有相关数据！</td></tr>
		      	</c:if>
		      	<c:if test="${! empty resumeList}">
			      	<c:forEach items="${resumeList }" var="resume" varStatus="vs">
				        <tr>
				          <td>${vs.count }</td>
				          <td>${resume.intention }</td>
				          <td>${resume.workExperience }</td>
				          <td>${resume.projectExperience }</td>
				          <td><a href="">修改</a> <a href="javascript:void(0)" onclick="del(this, ${resume.id})">删除</a>
				        </tr>
			        </c:forEach>
			     </c:if>
		      </tbody>
		    </table>
		    
	    	<span class="resume">应聘信息</span>
	    	<table class="table">
		      <thead>
		        <tr>
		          <th>序号</th>
		          <th>求职公司</th>
		          <th>求职职位</th>
		          <th>申请时间</th>
		          <th>当前状态</th>
		          <th>操作</th>
		        </tr>
		      </thead>
		      <tbody>
		      	<tr>
		          <td>序号</td>
		          <td>求职公司</td>
		          <td>求职职位</td>
		          <td>申请时间</td>
		          <td>当前状态</td>
		          <td><a href="">删除</a></td>
		        </tr>
		      </tbody>
		    </table>
    	</div>
    	
    	<script>
    		function del(obj, resumeId) {
    			/* 
	    			// 创建XMLHttpRequest。我在页面上不动，我准备委托一个人去帮我删除数据
	    			var xmlhttp;
					if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
					  xmlhttp=new XMLHttpRequest();
					} else { // code for IE6, IE5
					  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					
	    			// XMLHttpRequest请求。我把这个人派出去
	    			xmlhttp.open('GET', '<%=request.getContextPath()%>/ResumeServlet?command=delete&resumeId=' + resumeId + '&time=' + new Date().getTime(), true);
					xmlhttp.send();
	    			
					// 随时与这个人保持联系，方便及时知道结果
					xmlhttp.onreadystatechange=function() {
			    	  // XMLHttpRequest响应。这个人把事情做完了（删除数据），然后回来告诉我
					  if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					    var text = xmlhttp.responseText;
					    // 如果是成功了就在页面上删除当前a标签所在的tr，如果不成功给出提示
					    if (text == 'fail') {
					    	layer.msg('操作失败！', {time: 2000, icon: 5});
					    } else {
					    	layer.msg('操作成功！', {time: 2000, icon: 6});
					    	$(obj.parentNode.parentNode).remove();
					    }
					  }
					}
    		  */
    		  
    		  // $.get(url, function(data) {})
    		  $.get('<%=request.getContextPath()%>/ResumeServlet?command=delete&resumeId=' + resumeId + '&time=' + new Date().getTime(), function(text){
			     // 如果是成功了就在页面上删除当前a标签所在的tr，如果不成功给出提示
			     if (text == 'fail') {
			    	layer.msg('操作失败！', {time: 2000, icon: 5});
			     } else {
			    	layer.msg('操作成功！', {time: 2000, icon: 6});
			    	$(obj.parentNode.parentNode).remove();
			     }
    		  });
    		}
    	</script>
    	
    </body>
</html>
